import unittest

# 创建测试类
from parameterized import parameterized

import utils
from api.login_api import LoginApi


class TestLogin(unittest.TestCase):
    def setUp(self) -> None:
        self.longin = LoginApi()

    # 登录成功(正确的手机号和密码)
    @parameterized.expand(utils.read_json("login_case_data"))
    def test01_login_success(self, login_json, exp_success, exp_code, exp_msg):
        res = self.longin.login(login_json)
        # res_dict = res.json()
        # # 断言响应体的响应码
        # self.assertEqual(200, res.status_code)
        # # 断言响应体字典的值
        # self.assertEqual(True, res_dict.get("success"))
        # self.assertEqual(10000, res_dict.get("code"))
        # self.assertIn("操作成功", res_dict.get("message"))
        utils.common_assert(self, res, exp_success, exp_code, exp_msg)

    # def test02_login_json_is_none(self):
    #     res = self.longin.login()
    #     # res_dict = res.json()
    #     # # 断言响应体的响应码
    #     # self.assertEqual(200, res.status_code)
    #     # # 断言响应体字典的值
    #     # self.assertEqual(False, res_dict.get("success"))
    #     # self.assertEqual(99999, res_dict.get("code"))
    #     # self.assertIn("系统繁忙", res_dict.get("message"))
    #     utils.common_assert(self, res, False, 99999, "系统繁忙")
    #
    # def test03_login_passwordWrong(self):
    #     res = self.longin.login({"mobile": "13565498778", "password": "123456"})
    #     # res_dict = res.json()
    #     # 断言响应体的响应码
    #     # self.assertEqual(200, res.status_code)
    #     # # 断言响应体字典的值
    #     # self.assertEqual(False, res_dict.get("success"))
    #     # self.assertEqual(20001, res_dict.get("code"))
    #     # self.assertIn("密码错误", res_dict.get("message"))
    #     utils.common_assert(self, res, False, 20001, "密码错误")
